from flask import Blueprint
from peewee import DoesNotExist

from app.advices import views

bp = Blueprint("advices", __name__, url_prefix="/advices")


@bp.errorhandler(DoesNotExist)
def handle_not_exist(error):
    return "no record", 404


bp.add_url_rule(
    "/content/<int:content_id>",
    view_func=views.AdviceDeleteView.as_view("content_delete"),
    methods=["DELETE"],
)

bp.add_url_rule(
    "/content",
    view_func=views.AdvicesView.as_view("content"),
    methods=["GET", "POST"],
)
